<script setup lang="ts">
import { onMounted } from 'vue'

onMounted(() => {
  const container = document.querySelector('.container')
  if (container) {
    container.classList.add('animate')
  }
})
</script>

<template>
  <div class="container">
    <div class="error-code">
      <span class="digit">4</span>
      <span class="digit">0</span>
      <span class="digit">4</span>
    </div>
    <div class="error-message">页面未找到</div>
    <div class="sub-message">看起来你访问的页面不存在</div>
    <div class="particles">
      <div class="particle"></div>
      <div class="particle"></div>
      <div class="particle"></div>
      <div class="particle"></div>
      <div class="particle"></div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #fff;
  position: relative;
  overflow: hidden;

  &.animate {
    .digit {
      animation: digitAppear 0.5s ease-out forwards;
      opacity: 0;
      transform: translateY(20px);

      &:nth-child(1) {
        animation-delay: 0.1s;
      }
      &:nth-child(2) {
        animation-delay: 0.2s;
      }
      &:nth-child(3) {
        animation-delay: 0.3s;
      }
    }

    .error-message {
      animation: fadeIn 0.5s ease-out 0.5s forwards;
      opacity: 0;
    }

    .sub-message {
      animation: fadeIn 0.5s ease-out 0.7s forwards;
      opacity: 0;
    }
  }
}

.error-code {
  font-size: 120px;
  font-weight: bold;
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  position: relative;
}

.digit {
  background: linear-gradient(45deg, #00f2fe, #4facfe);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 10px rgba(79, 172, 254, 0.5);
}

.error-message {
  font-size: 32px;
  margin-bottom: 10px;
  color: #4facfe;
}

.sub-message {
  font-size: 18px;
  color: #a0a0a0;
}

.particles {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #4facfe;
  border-radius: 50%;
  animation: particleFloat 4s infinite ease-in-out;

  &:nth-child(1) {
    top: 20%;
    left: 10%;
    animation-delay: 0s;
  }
  &:nth-child(2) {
    top: 60%;
    left: 80%;
    animation-delay: 1s;
  }
  &:nth-child(3) {
    top: 40%;
    left: 30%;
    animation-delay: 2s;
  }
  &:nth-child(4) {
    top: 80%;
    left: 50%;
    animation-delay: 3s;
  }
  &:nth-child(5) {
    top: 10%;
    left: 70%;
    animation-delay: 4s;
  }
}

@keyframes digitAppear {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

@keyframes particleFloat {
  0%,
  100% {
    transform: translateY(0) translateX(0);
    opacity: 0.3;
  }
  50% {
    transform: translateY(-20px) translateX(10px);
    opacity: 0.8;
  }
}
</style>
